FLAGS= -g -o
CFLAGS= -g -c -fPIC -Wall -DUSER_MODE 
CC=gcc
LD=ld
CCP=g++
STRUCTOBJ= alloc_init.o cube_buddy.o cube_static.o cube_freepage.o cube_cache.o cube_dynamic.o cube_temp.o
LIBNAME=alloc
DEPENDLIB= -lstring

main: ../lib/lib$(LIBNAME).so  ../lib/lib$(LIBNAME).a test_main
test_main: test_main.c ../lib/lib$(LIBNAME).so 
	$(CC) $(FLAGS) test_main test_main.c -L../lib -l$(LIBNAME) $(DEPENDLIB)
../lib/lib$(LIBNAME).so: $(STRUCTOBJ)
	$(CC) -shared -o lib$(LIBNAME).so $(STRUCTOBJ)
	mv   lib$(LIBNAME).so ../lib
../lib/lib$(LIBNAME).a: $(STRUCTOBJ)
	ar rs liballoc.a $(STRUCTOBJ)
	mv    liballoc.a ../lib
cube_buddy.o:  cube_buddy.c  cube_buddy.h alloc_init.h ../include/alloc.h
	$(CC) $(CFLAGS) cube_buddy.c
cube_static.o:  cube_static.c  cube_static.h alloc_init.h ../include/alloc.h
	$(CC) $(CFLAGS) cube_static.c
cube_cache.o:	 cube_cache.c  cube_cache.h alloc_init.h ../include/alloc.h
	$(CC) $(CFLAGS) cube_cache.c
cube_dynamic.o:	 cube_dynamic.c  cube_dynamic.h alloc_init.h ../include/alloc.h
	$(CC) $(CFLAGS) cube_dynamic.c
cube_freepage.o:  cube_freepage.c  cube_freepage.h alloc_init.h ../include/alloc.h
	$(CC) $(CFLAGS) cube_freepage.c
cube_temp.o:  cube_temp.c  alloc_init.h ../include/alloc.h
	$(CC) $(CFLAGS) cube_temp.c
alloc_init.o:  alloc_init.c ../include/alloc.h
	$(CC) $(CFLAGS) alloc_init.c
clean:
	rm -f test_main *~ *.a *.o ../lib/liballoc.a
